package com.library.recommendBook.dao;

import com.framework.BaseDao;
import com.library.entity.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class RecommendBookDaoImpl extends BaseDao<RecommendBook,String> {

	public RecommendBook getRecommendBookById(Integer recommendBookId){
		try{
			return super.get(recommendBookId);
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}


	public void saveRecommendBook(RecommendBook recommendBook){
		try {
			this.save(recommendBook);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public void updateRecommendBook(RecommendBook recommendBook){
		try {
			this.update(recommendBook);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public List<RecommendBook> getAll(){
		try{
			return super.findByProperty("from RecommendBook", new Object[]{});
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}

	public void deleteRecommendBook(RecommendBook recommendBook){
		try {
			this.delete(recommendBook);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
